<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>苏仕达 - 功能手套定制专家 防切割手套 耐高温手套</title>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.png"/>
    <link rel="stylesheet" href="assets/css/swap.css"/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="assets/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="assets/css/owl.carousel.min.css"/>
    <link rel="stylesheet" href="assets/css/animate.min.css"/>
    <link rel="stylesheet" href="assets/css/jquery-ui.css"/>
    <link rel="stylesheet" href="assets/css/slick.css"/>
    <link rel="stylesheet" href="assets/css/chosen.min.css"/>
    <link rel="stylesheet" href="assets/css/pe-icon-7-stroke.css"/>
    <link rel="stylesheet" href="assets/css/magnific-popup.min.css"/>
    <link rel="stylesheet" href="assets/css/lightbox.min.css"/>
    <link rel="stylesheet" href="assets/js/fancybox/source/jquery.fancybox.css"/>
    <link rel="stylesheet" href="assets/css/jquery.scrollbar.min.css"/>
    <link rel="stylesheet" href="assets/css/mobile-menu.css"/>
    <link rel="stylesheet" href="assets/fonts/flaticon/flaticon.css"/>
    <link rel="stylesheet" href="assets/css/style.css"/>
</head>
<header th:replace="head :: html"></header>
<body class="details-page">


<div class="main-content main-content-details single left-sidebar">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="breadcrumb-trail breadcrumbs">
                    <ul class="trail-items breadcrumb">
                        <li class="trail-item trail-begin">
                            <a href="index.html">苏仕达手套</a>
                        </li>
                        <li class="trail-item">
                            <a href="productlist.html">产品列表</a>
                        </li>
                        <li class="trail-item trail-end active">
                            产品详情
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="content-area content-details col-lg-9 col-md-8 col-sm-12 col-xs-12">
                <div class="site-main">
                    <div class="details-product">
                        <div class="details-thumd">
                            <div class="image-preview-container image-thick-box image_preview_container">
                                <img id="img_zoom" src="" alt="img"/>
                                <!--<a href="#" class="btn-zoom open_qv"><i class="fa fa-search" aria-hidden="true"></i></a>-->
                            </div>
                            <!--<div class="product-preview image-small product_preview">
                                <div id="thumbnails" class="thumbnails_carousel owl-carousel" data-nav="true" data-autoplay="false" data-dots="false" data-loop="false" data-margin="10" data-responsive='{"0":{"items":3},"480":{"items":3},"600":{"items":3},"1000":{"items":3}}'>
                                    <a href="#" data-image="assets/images/productdetail/detail.jpg" data-zoom-image="assets/images/productdetail/detail.jpg" class="active">
                                        <img src="assets/images/productdetail/detail.jpg" data-large-image="assets/images/productdetail/detail.jpg" alt="img"/>
                                    </a>
                                    <a href="#" data-image="assets/images/details-item-2.jpg" data-zoom-image="assets/images/details-item-2.jpg">
                                        <img src="assets/images/details-item-2.jpg" data-large-image="assets/images/details-item-2.jpg" alt="img"/>
                                    </a>
                                    <a href="#" data-image="assets/images/details-item-3.jpg" data-zoom-image="assets/images/details-item-3.jpg">
                                        <img src="assets/images/details-item-3.jpg" data-large-image="assets/images/details-item-3.jpg" alt="img"/>
                                    </a>
                                    <a href="#" data-image="assets/images/details-item-4.jpg" data-zoom-image="assets/images/details-item-4.jpg">
                                        <img src="assets/images/details-item-4.jpg" data-large-image="assets/images/details-item-4.jpg" alt="img"/>
                                    </a>
                                </div>
                            </div>-->
                        </div>
                        <div class="details-infor">
                            <h1 class="product-title" id="prodcutname">
                            </h1>
                            <div class="stars-rating">
                                <div class="star-rating">
                                    <span id="productstar" class="star-5"></span>
                                </div>
                            </div>


                            <div class="availability">
                                产品型号.:
                                <a href="#" id="modelno">CH-1301</a>
                            </div>


                            <div id="productattribute">
                                <!--<div class="availability">
                                    执行标准:
                                    <a href="#" >EN388 4543</a>
                                </div>-->
                            </div>

                            <div class="variations">
                                <div class="attribute attribute_color">
                                    <div class="availability">
                                        尺寸:
                                    </div>
                                    <div class="list-size list-item">
                                        <select title="size" id="availablesize">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="group-button">
                                <div class="quantity-add-to-cart">
                                    <button class="single_add_to_cart_button button">联系我们</button>
                                </div>
                            </div>

                            <div th:if=" ${session.user} == 'admin'" class="availability">
                                <a data-toggle="modal" data-target="#myModal"> 编辑 </a>
                            </div>
                        </div>
                    </div>
                    <div class="tab-details-product">
                        <ul class="tab-link">
                            <li class="active">
                                <a data-toggle="tab" aria-expanded="true" href="#product-descriptions">产品描述 </a>
                            </li>
                            <!--<li class="">
                                <a data-toggle="tab" aria-expanded="true" href="#information">Information </a>
                            </li>-->
                            <li class="">
                                <a data-toggle="tab" aria-expanded="true" href="#reviews">客户评价</a>
                            </li>
                        </ul>
                        <div class="tab-container">
                            <div id="product-descriptions" class="tab-panel active">
                                <!--产品描述-->
                            </div>
                            <!--<div id="information" class="tab-panel">
                                <table class="table table-bordered">
                                    <tr>
                                        <td>Size</td>
                                        <td> XS / S / M / L </td>
                                    </tr>
                                    <tr>
                                        <td>Color</td>
                                        <td>White/ Black/ Teal/ Brown</td>
                                    </tr>
                                    <tr>
                                        <td>Properties</td>
                                        <td>Colorful Dress</td>
                                    </tr>
                                </table>
                            </div>-->
                            <div id="reviews" class="tab-panel">
                                <div class="reviews-tab">
                                    <div class="comments">
                                        <h2 class="reviews-title">
                                            1 review for
                                            <span>Ehpro Cold Steel</span>
                                        </h2>
                                        <ol class="commentlist">
                                            <li class="conment">
                                                <div class="conment-container">
                                                    <a href="#" class="avatar">
                                                        <img src="assets/images/avartar.jpg" alt="img"/>
                                                    </a>
                                                    <div class="comment-text">
                                                        <div class="stars-rating">
                                                            <div class="star-rating">
                                                                <span class="star-5"></span>
                                                            </div>
                                                            <div class="count-star">
                                                                (1)
                                                            </div>
                                                        </div>
                                                        <p class="meta">
                                                            <strong class="author">Cobus Bester</strong>
                                                            <span>-</span>
                                                            <span class="time">June 7, 2013</span>
                                                        </p>
                                                        <div class="description">
                                                            <p>Simple and effective design. One of my favorites.</p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                        </ol>
                                    </div>
                                    <div class="review_form_wrapper">
                                        <div class="review_form">
                                            <div class="comment-respond">
                                                <span class="comment-reply-title">Add a review </span>
                                                <form class="comment-form-review">
                                                    <p class="comment-notes">
                                                        <span class="email-notes">Your email address will not be published.</span>
                                                        Required fields are marked
                                                        <span class="required">*</span>
                                                    </p>
                                                    <div class="comment-form-rating">
                                                        <label>Your rating</label>
                                                        <p class="stars">
                                        						<span>
                                        							<a class="star-1" href="#"></a>
                                        							<a class="star-2" href="#"></a>
                                        							<a class="star-3" href="#"></a>
                                        							<a class="star-4" href="#"></a>
                                        							<a class="star-5" href="#"></a>
                                        						</span>
                                                        </p>
                                                    </div>
                                                    <p class="comment-form-comment">
                                                        <label>
                                                            Your review
                                                            <span class="required">*</span>
                                                        </label>
                                                        <textarea title="review" id="comment" name="comment" cols="45"
                                                                  rows="8"></textarea>
                                                    </p>
                                                    <p class="comment-form-author">
                                                        <label>
                                                            Name
                                                            <span class="">*</span>
                                                        </label>
                                                        <input title="author" id="author" name="author" type="text"
                                                               value=""/>
                                                    </p>
                                                    <p class="comment-form-email">
                                                        <label>
                                                            Email
                                                            <span class="">*</span>
                                                        </label>
                                                        <input title="email" id="email" name="email" type="email"
                                                               value=""/>
                                                    </p>
                                                    <p class="form-submit">
                                                        <input name="submit" type="submit" id="submit" class="submit"
                                                               value="Submit"/>
                                                    </p>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div style="clear: left;"></div>
                </div>
            </div>
            <div class="sidebar sidebar-details col-lg-3 col-md-4 col-sm-12 col-xs-12">
                <div class="wrapper-sidebar">
                    <!--<div class="widget widget-categories">
                        <h3 class="widgettitle">Categories</h3>
                        <ul class="list-categories">
                            <li>
                                <input type="checkbox" id="cb1" />
                                <label for="cb1" class="label-text">
                                    New Arrivals
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb2" />
                                <label for="cb2" class="label-text">
                                    Beverage
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb3" />
                                <label for="cb3" class="label-text">
                                    Citrus
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb4" />
                                <label for="cb4" class="label-text">
                                    Creamy
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb5" />
                                <label for="cb5" class="label-text">
                                    Best Seller
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb6" />
                                <label for="cb6" class="label-text">
                                    Fruity
                                </label>
                            </li>
                        </ul>
                    </div>-->
                    <div class="widget widget-related-products">
                        <h3 class="widgettitle">推荐产品</h3>
                        <div class="slider-related-products owl-slick nav-top-right equal-container"
                             data-slick='{"autoplay":false, "autoplaySpeed":1000, "arrows":true, "dots":false, "infinite":true, "speed":800, "rows":1}'
                             data-responsive='[{"breakpoint":"2000","settings":{"slidesToShow":1 }},{"breakpoint":"992","settings":{"slidesToShow":2}}]'>
                            <div id="relativeList">

                            </div>
                        </div>
                    </div>
                    <!--<div class="widget widget-banner">
                        <a href="#">
                            <img src="assets/images/widget-banner.jpg" alt="img"/>
                        </a>
                    </div>-->
                    <!--<div class="widget widget-testimonials">
                        <h3 class="widgettitle">Testimonials</h3>
                        <div class="slider-related-products owl-slick nav-top-right"  data-slick ='{"autoplay":false, "autoplaySpeed":1000, "arrows":true, "dots":false, "infinite":true, "speed":800, "rows":1}' data-responsive='[{"breakpoint":"991","settings":{"slidesToShow":1 }}]'>
                            <div class="testimonials-item">
                                <div class="Testimonial-inner">
                                    <div class="comment">
                                        Donec ligula mauris, posuere sed tincidunt a, facilisis id enim. Class aptent taciti sociosqu ad litora torquent per conubia.
                                    </div>
                                    <div class="author">
                                        <div class="avt">
                                            <img src="assets/images/member1.jpg" alt="img"/>
                                        </div>
                                        <h3 class="name">
                                            Adam Smith
                                            <span class="position">
                                                CEO/Founder Apple
                                            </span>
                                        </h3>

                                    </div>
                                </div>
                            </div>
                            <div class="testimonials-item">
                                <div class="Testimonial-inner">
                                    <div class="comment">
                                        Donec ligula mauris, posuere sed tincidunt a, facilisis id enim. Class aptent taciti sociosqu ad litora torquent per conubia.
                                    </div>
                                    <div class="author">
                                        <div class="avt">
                                            <img src="assets/images/member2.jpg" alt="img"/>
                                        </div>
                                        <h3 class="name">
                                            Tom Milikin
                                            <span class="position">
                                                CEO/Founder Apple
                                            </span>
                                        </h3>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>-->
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <form id="editProduct-form">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        编辑产品
                    </h4>
                </div>
                <div class="modal-body">
                    <table>
                        <tr>
                            <td>产品名称：<br/>
                                <input type="hidden" id="edit_ProductId" name="productId" value=""/>
                                <input type="text" id="edit_ProductName" name="productname" value=""/></td>
                            <td>星星数：<br/>
                                <input type="text" id="edit_Productstar" name="productstar" value=""/></td>
                        </tr>


                        <tr>
                            <td>缩略图：<br/><input type="text" name="thumbnailspicurl" id="edit_ThumbnailPic" value=""/>
                            </td>
                            <td>详细图：<br/><input type="text" name="detailpicurl" id="edit_DetailPic" value=""/></td>
                        </tr>

                        <tr>
                            <td colspan="2">产品属性：<br/><input style="width: 100%" type="text" name="productattribute"
                                                             id="edit_Productattribute" value=""/></td>
                        </tr>

                        <tr>
                            <td>产品型号：<br/><input type="text" name="modelno" id="edit_Modelno" value=""/></td>
                            <td>尺寸：<br/><input type="text" name="availablesize" id="edit_availablesize" value=""/></td>
                        </tr>

                        <tr>
                            <td colspan="2">产品标签：<br/><input style="width: 100%" type="text" name="producttags"
                                                             id="edit_ProductTags" value=""/></td>
                        </tr>

                        <tr>
                            <td colspan="2">关联产品id：<br/><input style="width: 100%" type="text" name="relativeId"
                                                               id="edit_RelativeId" value=""/></td>
                        </tr>

                        <tr>
                            <td colspan="2">产品描述：<textarea id="edit_PorductDesc" name="productdesc" rows="8" cols="30"
                                                           value=""/></td>
                        </tr>
                    </table>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" onclick="saveProduct()" class="btn btn-primary">
                        保存
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </form>
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<div th:replace="foot :: html"></div>


<script src="assets/js/jquery-1.12.4.min.js"></script>
<script src="assets/js/jquery.plugin-countdown.min.js"></script>
<script src="assets/js/jquery-countdown.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/owl.carousel.min.js"></script>
<script src="assets/js/magnific-popup.min.js"></script>
<script src="assets/js/isotope.min.js"></script>
<script src="assets/js/jquery.scrollbar.min.js"></script>
<script src="assets/js/jquery-ui.min.js"></script>
<script src="assets/js/mobile-menu.js"></script>
<script src="assets/js/chosen.min.js"></script>
<script src="assets/js/slick.js"></script>
<script src="assets/js/jquery.elevateZoom.min.js"></script>
<script src="assets/js/jquery.actual.min.js"></script>
<script src="assets/js/fancybox/source/jquery.fancybox.js"></script>
<script src="assets/js/lightbox.min.js"></script>
<script src="assets/js/owl.thumbs.min.js"></script>
<script src="assets/js/jquery.scrollbar.min.js"></script>
<!--<script src="assets/js/frontend-plugin.js"></script>-->

<script>

    /*<![CDATA[*/

    $(document).ready(function () {
        loadProduct();
    });


    function loadProduct() {
        var prodcutId = decodeURI(window.location.search.substring(1)).split("=")[1].split("#")[0];
        $.post("/api/product/showProductDetail.do",
            { //需要传入后代的数据
                prodcutId: prodcutId
            },
            function (message) {
                var result = message;
                $("#prodcutname").text(result.productinfo.productname);
                $("#productstar").attr("class", "star-" + result.productinfo.productstar);
                $("#modelno").text(result.productinfo.modelno);
                $("#standard").text(result.productinfo.standard);
                $("#img_zoom").attr("src", "assets/images/productdetail/" + result.productpicinfoList[0].picurl);
                loadRelativeProduct(result.productinfo.relativeId);
                if (result.productinfo.productattribute != null) {
                    var attributesArray = result.productinfo.productattribute.split(";");
                    var attributeHtml = "";
                    if (attributesArray != null && attributesArray.length > 0) {
                        for (var i = 0; i < attributesArray.length; i++) {
                            attributeHtml += '<div class="availability">'
                                + attributesArray[i].split(":")[0]
                                + ':<a href="#" >'
                                + attributesArray[i].split(":")[1]
                                + '</a></div>';
                            $("#productattribute").html(attributeHtml);
                        }
                    }
                }

                // 拆分
                if (result.productinfo.availablesize != null) {
                    var sizeHtml = "";
                    var sizeArray = result.productinfo.availablesize.split(";");
                    sizeArray.forEach(function (element, index, array) {
                        sizeHtml += "<option>" + element + "</option>";
                    });
                    $("#availablesize").html(sizeHtml);
                }

                $("#product-descriptions").html(result.productinfo.productdesc);
                $("#edit_ProductId").val(result.productinfo.id);
                $("#edit_Productstar").val(result.productinfo.productstar);
                $("#edit_Productattribute").val(result.productinfo.productattribute);
                $("#edit_availablesize").val(result.productinfo.availablesize);


                $("#edit_ProductName").val(result.productinfo.productname);
                $("#edit_ProductType").val(result.productinfo.producttype);
                $("#edit_PorductDesc").val(result.productinfo.productdesc);
                $("#edit_ThumbnailPic").val(result.productinfo.thumbnailspicurl);
                $("#edit_ProductTags").val(result.productinfo.producttags);
                $("#edit_RelativeId").val(result.productinfo.relativeid);

                $("#edit_Size").val(result.productinfo.availablesize);
                $("#edit_Modelno").val(result.productinfo.modelno);

                $("#edit_DetailPic").val(result.productpicinfoList[0].picurl);

            }
        );
        // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
        return false;
    }


    function saveProduct() {


        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/api/product/saveProduct.do",//url
            data: $('#editProduct-form').serialize(),
            success: function (message) {
                var result = message;
                alert(result.resultMessage);
                if (result.result) {
                    // 刷新页面
                    window.location.reload();
                }

            },
            error: function () {
                alert("保存异常！");
            }
        });
        // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
        return false;


    }

    function loadRelativeProduct(relativeIds) {
        $.post("/api/product/searchProduct.do",
            { //需要传入后代的数据
                relativeIds: relativeIds
            },
            function (message) {
                var productHtml = "";
                for (var i in message.productinfoList) {
                    productHtml +=
                        '<div class="product-item style-1"><div class="product-inner equal-element">' +
                        '<div class="product-top"><div class="flash"><span class="onnew"><span class="text">new</span></span></div></div><div class="product-thumb">' +
                        '<div class="thumb-inner"><a href="productdetails_leftsidebar.html?id=' + message.productinfoList[i].id + '">' +
                        '<img id="img_productDetail" src="assets/images/product/productlist/' + message.productinfoList[i].thumbnailspicurl + '" alt="img"/></div></div><div class="product-info">' +
                        '<h5  class="product-name product_title">' + message.productinfoList[i].productname + '</h5><div class="group-info"><div class="stars-rating">' +
                        '<div class="star-rating"><span class="star-' + message.productinfoList[i].productstar + '"></span></div></div>' +
                        '</div></div></div></div>';
                }
                $("#relativeList").html(productHtml);
            }
        );
    }


    /*]]>*/
</script>
</body>
</html>